package com.itheima.mapper;

import com.itheima.pojo.Flavors;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FlavorsMapper {
    /**
     * 新增口味
     */
    @Insert("insert into flavors(id,dishId,name,value,showOption)values (#{id},#{dishId},#{name},#{value},#{showOption}  )")
    int addFlavors(Flavors flavors);


    /**
     * 查询口味表数据
     */
    @Select("select * from flavors where dishId = #{id}")
    List<Flavors> selectFlavors(@Param("id") String id);

    /**
     * 修改口味
     */
    List<Flavors> updeteFlavors(Flavors flavors);


    /**
     * 删除口味表数据
     */
    @Delete("delete from flavors where dishId=#{dishId}")
    int deleteflavors(String dishId);


    /**
     * 根据id查询口味表数据
     */
    @Select("select * from flavors where id=#{id}")
    Flavors selectFlavorsById(String id);

    /**
     *  口味详情
     */
    @Select("select f.id,f.dishId,f.name,f.value from flavors f,dish d where f.dishId = d.id")
    List<Flavors> selectFlavorsDetails();

    void addListFlavors(List<Flavors> flavors);
}
